**********************************************************************************
**** Replication Data for: State-Building, Collective Efficacy, and the Co-Production of Public Goods in Rural Africa
*** Authors: Natalie Letsa and Martha Wilfahrt
** Journal: Comparative Political Studies
* File Date: 18 December 2025
**********************************************************************************

cd "/Users/marthawilfahrt/Library/CloudStorage/GoogleDrive-mawilfahrt@gmail.com/.shortcut-targets-by-id/1YQR2toLWEkHCV52GnykhtsVb1hWNDRS_/Colonial Legacies/Writing/Collective Efficacy Paper/Submissions/CPS/Letsa_Wilfahrt_CPS_Replication Files/"

****** FIGURE 1: Distribution of Collective Efficacy Factor Variable by Country
{
use "Datasets/Original_Survey.dta", clear

sum CollectiveEfficacy_Factor2 if Togo == 0
    local mw = r(mean)
	
histogram CollectiveEfficacy_Factor2 if Togo == 0, discrete percent fcolor(none)  xtitle("") xscale(range(0 1)) xlabel(0(1)5, ///
	labels labsize(vsmall) angle(forty_five) valuelabel) ylabel(0(20)80) ///
	xline(`mw', lwidth(medthick) lpattern(solid) lcolor(ebblue)) ///
	title(Ghana, margin(medium))
	
	graph save Graph "Ghana_CE Dist.gph", replace

	
sum CollectiveEfficacy_Factor2 if Togo == 1
    local mw = r(mean)
	
histogram CollectiveEfficacy_Factor2 if Togo == 1, discrete percent fcolor(none) xtitle("") xscale(range(0 1)) xlabel(0(1)5, ///
	labels labsize(vsmall) angle(forty_five) valuelabel) ylabel(0(20)80) ///
	xline(`mw', lwidth(medthick) lpattern(solid) lcolor(ebblue)) ///
	title(Togo, margin(medium))
	
		graph save Graph "Togo_CE Dist.gph", replace

graph combine "Ghana_CE Dist.gph" "Togo_CE Dist.gph"
	graph save Graph "Legislative Elec Figures/Occupation Dist_Combined.gph", replace

}

****** FIGURE 2: Did your village have any problem with public resources in the past year?
{
histogram Q23, discrete percent fcolor(ebblue) xlabel(0(1)1) by(Togo) xtitle("") ///
	 by(, note("")  title("a. Has your village had any problem like this in last year?", position(6)))
graph save Graph "VillageProblem.gph", replace

histogram Q24, discrete percent fcolor(ebblue) xlabel(0(1)1) by(Togo)  xtitle("") ///
	 by(, note("") title("b. Was the problem fixed?", position(6)))
graph save Graph "ProblemSolved.gph", replace

graph combine "VillageProblem.gph" "ProblemSolved.gph", ///
	row(1)  ycommon scheme(s1mono) 
}
			
****** FIGURE 3: Table 2 Replications excluding cross-border migrants. 
{
use "Datasets/Original_Survey.dta", clear

gen Nationality_Other = 0
replace Nationality_Other = 1 if Q2 == 1 & Togo == 1
replace Nationality_Other = 1 if Q2 == 2 & Togo == 0

gen Parent_Other = 0
replace Parent_Other = 1 if Q45 == 1 | Q45 == 2
replace Parent_Other = 1 if Q45_C_5 == "Mother"

gen Grandparent_Other = 0
replace Grandparent_Other = 1 if Q45 == 3 
replace Grandparent_Other = 1 if Q45_C_5 == "MES GRANDS PARENTS , ONCLES ET TANTES"

gen Migrant_2Gen = 0
replace Migrant_2Gen = 1 if Parent_Other == 1 & Nationality_Other == 0

gen Migrant_3Gen = 0
replace Migrant_3Gen = 1 if Grandparent_Other == 1 & Nationality_Other == 0 & Parent_Other == 0

gen AllMigrants = 0
replace AllMigrants = 1 if Nationality_Other == 1
replace AllMigrants = 1 if Migrant_2Gen == 1
replace AllMigrants = 1 if Migrant_3Gen == 1
replace AllMigrants = 1 if Village == 33

save "Datasets/Original_Survey_Migrants.dta", replace

* Self Migrated
use "Datasets/Original_Survey_Migrants.dta", clear

revrs Q83
rename revQ83 Coll_Eff1
rename Q84 Coll_Eff2
rename CollectiveEfficacy_Factor2 Coll_Eff3

reshape long Coll_Eff, i(InstanceID) j(item)

tab item, gen(i)
rename i3 self1

for var Age   Education2 Togo HH_SES  IndEfficacy_Factor Ethnic_Minority H6bpopulationest InfrastructureIndex: gen s_X1 = self1*X

gen vign1 = 1-self1
eq het: vign1 self1

constraint def 1 [lns1]self1=0

eq thresh: Age  Education2 Togo HH_SES  IndEfficacy_Factor Ethnic_Minority H6bpopulationest InfrastructureIndex

gllamm Coll_Eff s_Togo1 s_Age1  s_Education21 s_HH_SES1  s_IndEfficacy_Factor1 s_Ethnic_Minority1 s_H6bpopulationest1 s_InfrastructureIndex1 i1 i2 if Nationality_Other == 0 , robust/*
*/ i(InstanceID) link(soprobit) s(het) ethresh(thresh) constr(1) /*
*/ init

est sto Vignette_SelfMigrate

* 2 Gen (parents)
use "Datasets/Original_Survey_Migrants.dta", clear
 
 revrs Q83
rename revQ83 Coll_Eff1
rename Q84 Coll_Eff2
rename CollectiveEfficacy_Factor2 Coll_Eff3

reshape long Coll_Eff, i(InstanceID) j(item)

tab item, gen(i)
rename i3 self1

for var Age   Education2 Togo HH_SES  IndEfficacy_Factor Ethnic_Minority H6bpopulationest InfrastructureIndex: gen s_X1 = self1*X

gen vign1 = 1-self1
eq het: vign1 self1

constraint def 1 [lns1]self1=0

eq thresh: Age  Education2 Togo HH_SES  IndEfficacy_Factor Ethnic_Minority H6bpopulationest InfrastructureIndex

gllamm Coll_Eff s_Togo1 s_Age1  s_Education21 s_HH_SES1  s_IndEfficacy_Factor1 s_Ethnic_Minority1 s_H6bpopulationest1 s_InfrastructureIndex1 i1 i2 if Migrant_2Gen == 0 , robust/*
*/ i(InstanceID) link(soprobit) s(het) ethresh(thresh) constr(1) /*
*/ init

est sto Vignette_2gen


* 3 Gen (parents, respondent)
use "Datasets/Original_Survey_Migrants.dta", clear

revrs Q83
rename revQ83 Coll_Eff1
rename Q84 Coll_Eff2
rename CollectiveEfficacy_Factor2 Coll_Eff3

reshape long Coll_Eff, i(InstanceID) j(item)

tab item, gen(i)
rename i3 self1

for var Age   Education2 Togo HH_SES  IndEfficacy_Factor Ethnic_Minority H6bpopulationest InfrastructureIndex: gen s_X1 = self1*X

gen vign1 = 1-self1
eq het: vign1 self1

constraint def 1 [lns1]self1=0

eq thresh: Age  Education2 Togo HH_SES  IndEfficacy_Factor Ethnic_Minority H6bpopulationest InfrastructureIndex

gllamm Coll_Eff s_Togo1 s_Age1  s_Education21 s_HH_SES1  s_IndEfficacy_Factor1 s_Ethnic_Minority1 s_H6bpopulationest1 s_InfrastructureIndex1 i1 i2 if Migrant_3Gen == 0 , robust/*
*/ i(InstanceID) link(soprobit) s(het) ethresh(thresh) constr(1) /*
*/ init

est sto Vignette_3gen


* ALL MIGRANT HISTORY + VILLAGE THAT MOVED
use "Datasets/Original_Survey_Migrants.dta", clear

revrs Q83
rename revQ83 Coll_Eff1
rename Q84 Coll_Eff2
rename CollectiveEfficacy_Factor2 Coll_Eff3

reshape long Coll_Eff, i(InstanceID) j(item)

tab item, gen(i)
rename i3 self1

for var Age   Education2 Togo HH_SES  IndEfficacy_Factor Ethnic_Minority H6bpopulationest InfrastructureIndex: gen s_X1 = self1*X

gen vign1 = 1-self1
eq het: vign1 self1

constraint def 1 [lns1]self1=0

eq thresh: Age  Education2 Togo HH_SES  IndEfficacy_Factor Ethnic_Minority H6bpopulationest InfrastructureIndex

gllamm Coll_Eff s_Togo1 s_Age1  s_Education21 s_HH_SES1  s_IndEfficacy_Factor1 s_Ethnic_Minority1 s_H6bpopulationest1 s_InfrastructureIndex1 i1 i2 if AllMigrants == 0 , robust/*
*/ i(InstanceID) link(soprobit) s(het) ethresh(thresh) constr(1) /*
*/ init

est sto Vignette_AllMigrants

coefplot Vignette_SelfMigrate Vignette_2gen Vignette_3gen Vignette_AllMigrants, keep(s_Togo1) vertical levels(95 90) ///
	yline(0, lcolor(gs12) lwidth(thin)) msymbol(square_hollow) mcolor(black) ciopts(lcolor(black black)) ///
	ytitle(Coefficient for Togo) ylabel(-2(.5).5) ///
	xlabel(.7 "Respondent Migrated" .9 "Parents" 1.1 "Grandparents" 1.3 "Excluding all Migrants", labsize(small)) ///
	title("", size(medsmall)) legend(off) scheme(s1mono)

graph save Graph "Table Output/Migration_Vignettes.gph", replace

}

****** FIGURE 4: Perceived Changes in Collective Efficacy Over Time
{
use "Datasets/Original_Survey.dta", clear

label define Togo 0 "Ghana" 1 "Togo"
label values Togo Togo

histogram Q97, percent barwidth(.9) xlabel(, nolabels) xtitle("")  by(, title(1960s)  note("") legend(off)) by(Togo) 
graph save Graph "Sixties.gph", replace

histogram Q95, percent barwidth(.9) xtitle("") xlabel(1(1)5,  valuelabel) by(, title(1980s)  note("") legend(off)) by(Togo) 
graph save Graph "Eighties.gph", replace

graph combine "Sixties" "Eighties", ///
	title("Do you think people in the village were more or less likely to help each other than they are today?")  ///
	col(1)
}

